/*
 * Copyright (C) 2008 by Xume.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.xume.critann.jpa.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * $Id: Books.java 15 2008-10-12 10:46:49Z jsiebens $
 * 
 * @author Johan Siebens
 */
public class Books {

	public static final Book ANT_IN_ACTION = createBook(4, "Ant in Action", null, "2007-06-01", 600);

	public static final Double AVG = new Double(635);

	public static final Long COUNT = new Long(7);

	public static final Book EJB3_IN_ACTION = createBook(5, "EJB 3 in Action", null, "2007-03-01", 712);

	public static final Book GWT_IN_PRACTICE = createBook(2, "GWT in Practice", null, "2008-05-01", 376);

	public static final Book ITEXT_IN_ACTION = createBook(6, "iText in Action", null, "2006-12-01", 688);

	public static final Book JAVA_PERSISTENCE_WITH_HIBERNATE = createBook(7, "Java Persistence with Hibernate",
			"Second Edition of Hibernate in Action", "2006-11-01", 880);

	public static final Integer MAX = new Integer(880);

	public static final Integer MIN = new Integer(376);

	public static final Long ROW_COUNT = new Long(7);

	public static final Book SPRING_IN_ACTION_SECOND_EDITION = createBook(3, "Spring in Action, Second Edition", null, "2007-08-01", 768);

	public static final Book STRUTS2_IN_ACTION = createBook(1, "Struts 2 in Action", null, "2008-05-01", 424);

	public static final Long SUM = new Long(4448);

	private static Book createBook(long id, String title, String subTitle, String releaseDate, int numberOfPages) {
		Book book = new Book();
		book.setId(id);
		book.setTitle(title);
		book.setSubTitle(subTitle);
		book.setNumberOfPages(numberOfPages);
		try {
			book.setReleaseDate(new SimpleDateFormat("yyyy-MM-dd").parse(releaseDate));
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
		return book;
	}
}
